﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
        <link type="text/css" rel="stylesheet" media="all" href="../styles/global.css" />
        <link type="text/css" rel="stylesheet" media="all" href="../styles/global_color.css" />
        <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
        <script src="/js/role/all_module.js"></script>
        <script language="javascript" type="text/javascript">
            //保存成功的提示消息
            function showResult() {
                showResultDiv(true);
                window.setTimeout("showResultDiv(false);", 3000);
            }
            function showResultDiv(flag) {
                var divResult = document.getElementById("save_result_info");
                if (flag)
                    divResult.style.display = "block";
                else
                    divResult.style.display = "none";
            }
        </script>
    </head>
    <body>
        <!--Logo区域开始-->
        <div id="header">
            <img src="../images/logo.png" alt="logo" class="left"/>
            <a href="/login.html">[退出]</a>
        </div>
        <!--Logo区域结束-->
        <!--导航区域开始-->
        <div id="navi">
            <ul id="menu">
                <li><a href="../index.html" class="index_off"></a></li>
                <li><a href="../role/role_list.html" class="role_on"></a></li>
                <li><a href="../admin/admin_list.html" class="admin_off"></a></li>
                <li><a href="../fee/fee_list.html" class="fee_off"></a></li>
                <li><a href="../account/account_list.html" class="account_off"></a></li>
                <li><a href="../service/service_list.html" class="service_off"></a></li>
                <li><a href="../bill/bill_list.html" class="bill_off"></a></li>
                <li><a href="../report/report_list.html" class="report_off"></a></li>
                <li><a href="../user/user_info.html" class="information_off"></a></li>
                <li><a href="../user/user_modi_pwd.html" class="password_off"></a></li>
            </ul>
        </div>
        <!--导航区域结束-->
        <!--主要区域开始-->
        <div id="main">           
            <!--保存操作后的提示信息：成功或者失败-->
            <div id="save_result_info" class="save_success">保存成功！</div>
            <form action="/role/updRole" method="post" class="main_form">
                <div class="text_info clearfix"><span>角色名称：</span></div>
                <div class="input_info">
                    <input type="text" class="width200" name="roleName" required value="超级管理员" />
                    <span class="required">*</span>
                    <div class="validate_msg_medium error_msg">不能为空，且为20长度的字母、数字和汉字的组合</div>
                </div>
                <div>
                    <span id="roles" class="hint"></span>
                </div>
                <br>
                <div class="text_info clearfix"><span>设置权限：</span></div>
                <div class="input_info_high">
                    <div class="input_info_scroll">
                        <ul id="ul">
                        </ul>
                    </div>
                    <span class="required">*</span>
                    <div class="validate_msg_tiny">至少选择一个权限</div>
                </div>
                <div class="button_info clearfix">
                    <input type="hidden" name="roleId" id="roleId"/>
                    <input type="submit" value="保存" class="btn_save" id="btn_save" />
                    <input type="button" value="取消" class="btn_save btn_cancel" />
                </div>
            </form> 
        </div>
        <!--主要区域结束-->
        <div id="footer">
            <span>[源自北美的技术，最优秀的师资，最真实的企业环境，最适用的实战项目]</span>
            <br />
             <span>版权所有(C)云科技有限公司 </span>
        </div>
    </body>
<script>


    var roleId = window.localStorage.getItem('roleId')
    var roleName = window.localStorage.getItem('roleName')
    var allModule = window.localStorage.getItem('allModule')


        $('.width200').val(roleName)
        $('#roleId').val(roleId)
    let roles = $('#roles')
    if (allModule == null || allModule == ""){
        roles.text("该角色当前没有可以管理的模块")
    } else{
        roles.text("该角色能操作模块为:" + allModule.split(",").join('&'))
    }

         window.localStorage.removeItem('roleId')
         window.localStorage.removeItem('roleName')
         window.localStorage.removeItem('allModule')



    $('.btn_cancel').click(function () {

        window.location.href='/role/role_list.html'
    })




    $('#btn_save').click(function () {
        let roleName = $('input[name="roleName"]').val();

        let reg = /[0-9a-zA-Z\u4e00-\u9fa5]{1,20}$/
        if (!reg.test(roleName)){
            alert('角色名称的格式不正确');
            return false
        }
        if (roleName.length > 20){
            alert('角色名称的长度不能超过20')
            return false
        }
        showResult();

    })
</script>
</html>
